(function(vc,vm){

    vc.extends({
        data:{
            editAffiliateRelationInfo:{
                arId:'',
name:'',
expireTime:'',

            }
        },
         _initMethod:function(){

         },
         _initEvent:function(){
             vc.on('editAffiliateRelation','openEditAffiliateRelationModal',function(_params){
                vc.component.refreshEditAffiliateRelationInfo();
                $('#editAffiliateRelationModel').modal('show');
                vc.copyObject(_params, vc.component.editAffiliateRelationInfo );
                vc.component.editAffiliateRelationInfo.communityId = vc.getCurrentCommunity().communityId;
            });
        },
        methods:{
            editAffiliateRelationValidate:function(){
                        return vc.validate.validate({
                            editAffiliateRelationInfo:vc.component.editAffiliateRelationInfo
                        },{
                            'editAffiliateRelationInfo.name':[
{
                            limit:"required",
                            param:"",
                            errInfo:"关系层级不能为空"
                        },
 {
                            limit:"maxLength",
                            param:"30",
                            errInfo:"关系层级不能超过30"
                        },
                    ],
'editAffiliateRelationInfo.expireTime':[
{
                            limit:"required",
                            param:"",
                            errInfo:"过期时间不能为空"
                        },
 {
                            limit:"maxLength",
                            param:"200",
                            errInfo:"过期时间不能为空"
                        },
                    ],
'editAffiliateRelationInfo.arId':[
{
                            limit:"required",
                            param:"",
                            errInfo:"关系ID不能为空"
                        }]

                        });
             },
            editAffiliateRelation:function(){
                if(!vc.component.editAffiliateRelationValidate()){
                    vc.toast(vc.validate.errInfo);
                    return ;
                }

                vc.http.apiPost(
                    'affiliateRelation.updateAffiliateRelation',
                    JSON.stringify(vc.component.editAffiliateRelationInfo),
                    {
                        emulateJSON:true
                     },
                     function(json,res){
                        //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
                        let _json = JSON.parse(json);
                        if (_json.code == 0) {
                            //关闭model
                            $('#editAffiliateRelationModel').modal('hide');
                             vc.emit('affiliateRelationManage','listAffiliateRelation',{});
                            return ;
                        }
                        vc.message(_json.msg);
                     },
                     function(errInfo,error){
                        console.log('请求失败处理');

                        vc.message(errInfo);
                     });
            },
            refreshEditAffiliateRelationInfo:function(){
                vc.component.editAffiliateRelationInfo= {
                  arId:'',
name:'',
expireTime:'',

                }
            }
        }
    });

})(window.vc,window.vc.component);
